package xyz.iguilty.workflow.model;

import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

@Getter@Setter
@AllArgsConstructor@NoArgsConstructor
public final class PageInfo<T> implements Serializable {

    @ApiModelProperty(value = "数据", required = true)
    private List<T> records;

    @ApiModelProperty(value = "总量", required = true)
    private Long total;

    public static <T> PageInfo<T> build(List<T> records,Long total) {
        PageInfo<T> pageInfo = new PageInfo<>();
        pageInfo.setRecords(records);
        pageInfo.setTotal(total);
        return pageInfo;
    }
    public static <T> PageInfo<T> empty() {
        PageInfo<T> pageInfo = new PageInfo<>();
        pageInfo.setRecords(Collections.emptyList());
        pageInfo.setTotal(0L);
        return pageInfo;
    }
}